package com.test.socket;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * Created by jl on 2016/8/26.
 */
public class MyServerSocket {
    public static void main(String[] args) throws IOException {
        ServerSocket server = new ServerSocket(8084);
        while (true) {
            Socket socket = server.accept();
            //handle
            Thread worker = new ServerThread(socket);
            worker.start();
        }
//        BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
//        PrintWriter writer = new PrintWriter(socket.getOutputStream());
//        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
//
//        System.out.println("from client:" + reader.readLine());
//        String readLine = bufferedReader.readLine();
//        while (!"bye".equals(readLine)) {
//            writer.println(readLine);
//            writer.flush();
//            System.out.println("to client:" + readLine);
//            readLine = bufferedReader.readLine();
//        }
//        reader.close();
//        writer.close();
//        socket.close();
    }
}
